#!/bin/bash

# Tiny QA - Ollama服务检查脚本

echo "========================================"
echo "Tiny QA - Ollama服务检查"
echo "========================================"

# 检查Ollama是否安装
if ! command -v ollama &> /dev/null; then
    echo "❌ 错误: Ollama未安装"
    echo "请访问 https://ollama.ai 下载并安装Ollama"
    exit 1
fi

echo "✅ Ollama已安装"
ollama --version

# 检查Ollama服务是否运行
echo ""
echo "🔍 检查Ollama服务状态..."

if curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
    echo "✅ Ollama服务正在运行"
    
    # 获取模型列表
    echo ""
    echo "📋 已安装的模型:"
    ollama list
    
else
    echo "❌ Ollama服务未运行"
    echo ""
    echo "🚀 启动Ollama服务..."
    echo "ollama serve"
    echo ""
    echo "💡 提示: 请在新终端中运行 'ollama serve' 启动服务"
    exit 1
fi

# 检查推荐模型
echo ""
echo "🔍 检查推荐模型..."

if ollama list | grep -q "qwen2.5:7b"; then
    echo "✅ 推荐模型 qwen2.5:7b 已安装"
else
    echo "⚠️ 推荐模型 qwen2.5:7b 未安装"
    echo ""
    echo "📥 下载推荐模型:"
    echo "ollama pull qwen2.5:7b"
    echo ""
    echo "💡 提示: 建议下载推荐模型以获得最佳体验"
fi

echo ""
echo "========================================"
echo "检查完成！"
echo "========================================"
echo ""
echo "📋 常用Ollama命令:"
echo "启动服务: ollama serve"
echo "下载模型: ollama pull <model_name>"
echo "查看模型: ollama list"
echo "运行模型: ollama run <model_name>"
echo "删除模型: ollama rm <model_name>" 